/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




package learn.round1A;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.Scanner;

/**
 *
 * @author robit
 */
public class Join_K {

    Object member;
    Join_K(){}

    private static Scanner s = null;
    private static PrintWriter o = null;
    /**
    * calculate the answer
    * 3 ≤ K ≤ N.
    * 3 ≤ N ≤ 50.
    */
    private static String reckon() {
        int N=Int();
        int K=Int();

        char board[][]= null;
        int rowSize[]=null;
        boolean firsttime=true;
        int idx=0;int height=0;

        for(int i=N;i>0;i--){
            //System.out.print(i);
            String str = String();           
            if(str.contains("R")||str.contains("B")){
                if(firsttime){
                    height=i;
                    board=new char[height][N];
                    rowSize=new int[height];
                    firsttime=false;
                }
                int nonblank=0;
                for(int j=N;j>0;j--){
                    char c=str.charAt(j-1);
                    switch(c){
                        case '.':break;
                        case 'R':board[idx][nonblank++]=c;break;
                        case 'B':board[idx][nonblank++]=c;break;
                    }
                }
                rowSize[idx]=nonblank;
                idx++;
            }
            
        }
        if (height<1)return "Neither";
        
        for(int i= 0;i<height;i++){
            for(int j=0;j<board[i].length;j++){
                System.out.print(board[i][j]);
            }
            System.out.println();
        }

        Helper myhelper = new Helper(N, K, rowSize, board);
        myhelper.loop(Helper.WEST);
        myhelper.loop(Helper.SOUTHWEST);
        myhelper.loop(Helper.SOUTH);
        myhelper.loop(Helper.SOUTHEAST);
        System.out.println("R,B:"+myhelper.Rmax+","+myhelper.Bmax);
        if(myhelper.Rmax>=K){
            if(myhelper.Bmax>=K)return "Both";
            else return "Red";
        }else if (myhelper.Bmax>=K){
            return "Blue";
        }else return "Neither";
        
    }

    static class Helper{
        final static int SOUTHWEST=-1;
        final static int SOUTHEAST=-2;
        final static int SOUTH=-3;
        final static int WEST=-4;

        int N,K;
        int [] rowSize;
        char board[][];
        int height,width;

        int Rmax=0,Bmax=0;
        public Helper(int N, int K, int []rowSize, char board[][]) {
            this.K=K;
            this.N=N;
            this.rowSize=rowSize;
            this.board=board;
            this.height=board.length;
            this.width=board[height-1].length;
        }
        int calculateRow(int rloop,int cloop,int dir){
            return (dir==WEST)?cloop:rloop;
        }
        int calculateCol(int rloop,int cloop,int dir){
            switch(dir){
                case SOUTHWEST:return (rloop+cloop)%width;
                case SOUTHEAST:return (cloop-width-rloop)%width+width;
                case WEST:return rloop;
                default: return cloop;
            }
        }
        boolean isNewEntry(int row, int col,int dir){
            switch(dir){
                case SOUTHWEST:return col==0;
                case SOUTHEAST:return col==width-1;
            }
            return false;
        }
        String loop(int dir){
                        
            int lastColor ='W';
            int R=0,B=0;
            int cbound=(dir==WEST)?height:width;
            int rbound=(dir==WEST)?width:height;
            for(int cloop=0;cloop<cbound;cloop++){
                for(int rloop=0;rloop<rbound;rloop++){
                    int row =calculateRow(rloop, cloop, dir);
                    int col =calculateCol(rloop, cloop, dir);
                    //start new diagonal
                    if(isNewEntry(row, col, dir)){
                        lastColor='W';
                        R=B=0;
                    }

                    if(isBlank(row, col)){
                        lastColor='W';
                        R=B=0;
                    }
                    else if(lastColor == board[row][col])
                    {
                        switch(board[row][col]){
                            case 'R':Rmax=Math.max(Rmax, ++R);break;
                            case 'B':Bmax=Math.max(Bmax, ++B);break;
                        }
                    }else{
                        switch(board[row][col]){
                            case 'R':Rmax=Math.max(Rmax,++R);B=0;break;
                            case 'B':Bmax=Math.max(Bmax,++B);R=0;break;
                        }
                        lastColor=board[row][col];
                    }
                }
                
                lastColor='W';
                R=B=0;
             }

            
            return null;
        }
        boolean isBlank(int row,int col){
            return (col>=rowSize[row]);
        }
        boolean isOutOfBound(int row,int col){
            return(row<0||row>=height||col<0||col>=width);
        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        
        try {
            //String filename="test";
            String filename="A-small-practice";

            s = new Scanner(
                    new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
            o = new PrintWriter(
                    new BufferedWriter(new FileWriter(filename+".out")));

            // Determine input line number
            int lineNums = s.nextInt();

            for (int i = 1; i <= lineNums; i++) {
                o.println("Case #" + i + ": " + reckon());
            }
        } finally {
            s.close();
            o.close();
        }
    }


    private static int Int(){
        return s.nextInt();
    }
    private static long Long(){
        return s.nextLong();
    }
    private static String String(){
        return s.next();
    }

}
